<?php
namespace App\Services\Oauth\Oauth2;

use App\Core\Entity\BaseEntity;


class Base extends BaseEntity
{
    public function __construct(array $data = array())
    {
        parent::__construct($data);
    }

    /**
     * 获取命名 eg tongwei.cn
     * @param $url
     * @return string
     */
    public function baseUrl($url)
    {
        $hostName = $this->parseUrl($url, PHP_URL_HOST);
        $urlArr = explode('.', $hostName);
        return $urlArr[1] . '.' . $urlArr[2];
    }

    /**
     * 将url解析成数组
     *
     * @param $url
     * @param string $component
     * @return mixed
     */
    public function parseUrl($url, $component = '')
    {
        return parse_url($url, $component);
    }

}